const ll inf = 1e18;
void solve()
{
  int n, m, k, q;
  cin >> n >> m >> k >> q;

  vi pos, col, l(n + 1, m + 1), r(n + 1, 0);
  pos.pb(1);
  int mxt = 1;
  rep(i, 1, k) {
    int x, y;
    cin >> x >> y;
    r[x] = max(r[x], y);
    l[x] = min(l[x], y);
    pos.pb(x);
    mxt = max(mxt, x);
  }
  rep(i, 1, q) {
    int j;
    cin >> j;
    col.pb(j);
  }
  sort(all(col));
  sort(all(pos));
  pos.erase(unique(all(pos)), pos.end());

  vector<array<ll, 2>> dp(sz(pos), {inf, inf});
  if (!r[1]) {
    dp[0][0] = dp[0][1] = 0;
    l[1] = r[1] = 1;
  } else {
    dp[0][0] = r[1] - 1 + r[1] - l[1];
    dp[0][1] = r[1] - 1;
  }

  auto calc = [&](int p, int t, int q) {
    auto it = lower_bound(all(col), p);
    ll ret = inf;
    if (it != col.end()) {
      ret = min(ret, 0ll + abs(*it - p) + abs(t - *it) + abs(t - q));
    }
    if (it != col.begin()) {
      it = prev(it);
      ret = min(ret, 0ll + abs(*it - p) + abs(t - *it) + abs(t - q));
    }
    return ret;
  };

  rep(i, 1, sz(pos) - 1) {
    int pre = pos[i - 1], cur = pos[i];
    dp[i][0] = min(calc(l[pre], r[cur], l[cur]) + dp[i - 1][0], calc(r[pre], r[cur], l[cur]) + dp[i - 1][1]);
    dp[i][1] = min(calc(l[pre], l[cur], r[cur]) + dp[i - 1][0], calc(r[pre], l[cur], r[cur]) + dp[i - 1][1]);
  }
  cout << min(dp[sz(pos) - 1][0], dp[sz(pos) - 1][1]) + mxt - 1;
}